﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using Windows.Storage;
using System.Threading.Tasks;
using MusicExplorer.Repository;

namespace MusicExplorer.Test
{
    [TestClass]
    public class RepositoryTest
    {
        private static string sourceFolder = string.Format(@"{0}\FileSource\%%REPO%%\%%NAME%%",
            Windows.ApplicationModel.Package.Current.InstalledLocation.Path);

        private static string GetPath(string repo, string name)
        {
            return sourceFolder.Replace("%%REPO%%", repo).Replace("%%NAME%%", name);
        }

        [TestMethod]
        public async Task WorldOfHouseTest()
        {
            // Step 1 : Search for artist
            //var repository = new WorldOfHouseRepository();
            //var source = await RepositoryHelper.GetLocalSource(GetPath("WorldOfHouse", "woh_searchartists.htm"));
            //var artists = await repository.DecodeArtists(source);

            // Step 1 : Get genres
            var repository = new WorldOfHouseRepository();
            var source = await RepositoryHelper.GetLocalSourceAsync(GetPath("WorldOfHouse", "woh_searchgenres.htm"));
            var artists = await repository.DecodeGenres(source);

            // Step 2 : Get tracks by genre
            source = await RepositoryHelper.GetLocalSourceAsync(GetPath("WorldOfHouse", "woh_searchtracks.htm"));
            var tracks = await repository.DecodeTracks(source);
        }
    }
}
